from app.dao.base import BaseDao
from app.schema.message import *

from ..model.message import Message
from ..model.chat import Chat
class MessageDao(BaseDao):
    
    Model=Message
    async def search_by_chat_id(self, chat_id: int):
        return self.db.sess.query(Message).filter(
            Message.chat_id == chat_id,
            Message.is_deleted == 0
        ).order_by(Message.id.desc()).first()